<template>
  <section>

    <van-list
            v-model="loading"
            :finished="finished"
            finished-text="没有更多了"
            @load="onLoad"
    >
      <!-- <van-cell v-for="(item, index) in dataType" :key="item" :title="index" /> -->
      <!--<div class="detail-form-list-div"  v-for="(item, index) in dataType" :key="index">-->

      <!--</div>-->
      <div class="facility-detail-tab"  v-for="(item, index) in dataType" :key="index">
        <div class="facility-detail-tab-top">
          <div class="facility-detail-tab-top-left">
            <img class="facility-detail-tab-top-img" src="../../../../../assets/icon-time.png" />
            <div>{{item.submitTime}}</div>
            <img class="facility-detail-tab-top-img2" src="../../../../../assets/icon-tel.png" />
          </div>
          <div @click="showChange2(index, item.id)">
            <img class="facility-detail-tab-top-img3-t" v-if="index == tabIdx" src="../../../../../assets/icon-bottom.png" />
            <img class="facility-detail-tab-top-img3" v-else src="../../../../../assets/icon-bottom.png" />
          </div>
        </div>

        <div  v-if="index == tabIdx">
          <div class="facility-detail-tab-top-line2"></div>
          <div class="facility-detail--con">{{item.medictionName}}</div>
          <div class="facility-detail-tps">
            <div class="facility-detail-tps-div">
              <div class="facility-detail-tps-div-name">药品类型:</div>
              <div  class="facility-detail-tps-div-msg">{{resultDetail.medictionType}}</div>
            </div>
            <div class="facility-detail-tps-div">
              <div class="facility-detail-tps-div-name">计量单位:</div>
              <div  class="facility-detail-tps-div-msg">{{resultDetail.measurement}}</div>
            </div>
            <div class="facility-detail-tps-div">
              <div class="facility-detail-tps-div-name">药品数量:</div>
              <div  class="facility-detail-tps-div-msg">{{resultDetail.quantity}}</div>
            </div>
            <div class="facility-detail-tps-div">
              <div class="facility-detail-tps-div-name">药品前库存:</div>
              <div  class="facility-detail-tps-div-msg">{{resultDetail.quantityBefore}}</div>
            </div>
            <div class="facility-detail-tps-div">
              <div class="facility-detail-tps-div-name">领出小组:</div>
              <div  class="facility-detail-tps-div-msg">{{resultDetail.teamName}}</div>
            </div>
            <div  class="facility-detail-tps-div-t">
              <div class="facility-detail-tps-div-name">初次使用日期:</div>
              <div  class="facility-detail-tps-div-msg">{{resultDetail.submitTime}}</div>
            </div>
          </div>
          <div class="facility-detail-tab-top-line2"></div>
          <div class="detail-form-tipscon">
            <div class="detail-form-tips-con">操作人:{{resultDetail.createUser}}</div>
            <!--<div class="detail-form-tips-con">报表来源:来源 移动端</div>-->
            <div class="detail-form-tips-con">报表来源:来源<span v-if="resultDetail.source == 0">移动端</span><span v-else>pc端</span></div>
          </div>
        </div>
        <div class="facility-detail-tab-top-line"  v-show="index !== tabIdx"></div>
        <div class="facility-detail-tabs"  v-show="index !== tabIdx">
          <div class="facility-detail-tabs-name">{{item.createUser}}</div>
          <div class="facility-detail-tabs-line"></div>
          <div class="facility-detail-tabs-t">
            <div class="facility-detail-tabs-tips">{{item.medictionName}}</div>
            <div class="facility-detail-tabs-tips">{{item.operationName}}</div>
          </div>
        </div>
      </div>
    </van-list>
  </section>
</template>

<script>
import { getDate } from '../../../../../api/unit.js'
export default {
  props: {
    dataType: Array,
    tabIdx: Number,
    pageCount: Number,
    pageSize: Number,
    resultDetail: Object
  },
  data () {
    return {
      loading: false,
      finished: false
    }
  },
  filters: {
    format: function (value) {
      return getDate(value).nTime
    }
  },
  methods: {
    onLoad () {
      setTimeout(() => {
        if (this.dataType.length < this.pageCount && this.pageCount > this.pageSize) {
          this.pageChange()
        }
        // 加载状态结束
        this.loading = false

        // 数据全部加载完成
        if (this.dataType.length >= this.pageCount) {
          this.finished = true
        }
      }, 1000)
    },
    showChange2 (index, id) {
      this.$emit('showChange', index, id, 6)
    },
    pageChange () {
      this.$emit('pageChange')
    }
  }
}
</script>

<style scoped>
  .facility-detail-tab{
    margin-top: 16px;
    background: #fff;
    width: 690px;
    border-radius: 10px;
  }
  .facility-detail-tab-top{
    height: 95px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 32px;
    color: #9E9E9E;
    width: 690px;
  }
  .facility-detail-tab-top-left{
    display: flex;
    align-items: center;
  }
  .facility-detail-tab-top-img{
    width: 35px;
    height: 35px;
    margin-left: 37px;
    margin-right: 19px;
  }
  .facility-detail-tab-top-img2{
    width: 14px;
    height: 20px;
    margin-left: 23px;
  }
  .facility-detail-tab-top-img3{
    width: 22px;
    height: 12px;
    margin-right: 54px;
  }
  .facility-detail-tab-top-img3-t{
    width: 22px;
    height: 12px;
    margin-right: 54px;
    transform: rotate(180deg);
  }
  .facility-detail-tab-top-line{
    width:690px;
    height:2px;
    background: #000;
    opacity:0.14;
  }
  .facility-detail-tab-top-line2{
    width:590px;
    margin-left: 50px;
    height:2px;
    background: #000;
    opacity:0.14;
  }
  .facility-detail--con{
    color: #202020;
    font-size: 30px;
    font-weight: bold;
    margin-left: 50px;
    margin-top: 45px;
  }
  .facility-detail-tabs{
    display: flex;
    align-items: center;
    padding: 14px 0 9px 0;
  }
  .facility-detail-tabs-name{
    font-size: 34px;
    color: #202020;
    margin-left: 38px;
  }
  .facility-detail-tabs-line{
    width:2px;
    height:80px;
    opacity:0.14;
    background: #000;
    margin: 0 24px;
  }
  .facility-detail-tabs-tips{
    font-size: 26px;
    color: #9E9E9E;
    padding: 7px 12px;
    border: 2px solid #DEDBDE;
    border-radius:6px;
    margin-right: 13px;
  }
  .facility-detail-tabs-t{
    display: flex;
  }
  .facility-detail-tps{
    /*width: 590px;*/
    margin-left: 50px;
    display: flex;
    flex-wrap: wrap;
  }
  .facility-detail-tps-div{
    display: flex;
    margin-top: 29px;
    width: 285px;
    padding-left: 16px;
    font-size: 26px;
  }
  .facility-detail-tps-div-name{
    color: #202020;
    margin-right: 30px;
  }
  .facility-detail-tps-div-msg{
    color: #9E9E9E;
  }
  .facility-detail-tps-div-t{
    width: 500px;
    font-size: 26px;
    display: flex;
    padding-left: 16px;
    margin-top: 32px;
    margin-bottom: 39px;
  }
  .detail-form-tipscon{
    margin-left: 50px;
    display: flex;
    font-size: 26px;
    color: #9e9e9e;
    margin-top: 30px;
    padding-bottom: 42px;
  }
  .detail-form-tips-con{
    width: 300px;
  }
</style>
